package bg.btanev.eightyfour.domain.person;

import org.apache.commons.lang.Validate;

import bg.btanev.eightyfour.domain.entitybase.DomainValue;

/**
 *
 * @author B.Tanev
 *
 */
public class PersonName implements DomainValue {
	/**
	 *
	 */
	private static final long serialVersionUID = -8233950675223443986L;

	private String firstName;
	private String surName;
	private String lastName;

	protected PersonName() {
		super();
	}

	public PersonName(String firstName, String surName, String lastName) {
		super();

		Validate.notEmpty(firstName);
		Validate.notEmpty(lastName);

		this.firstName = firstName;
		this.surName = surName;
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getSurName() {
		return surName;
	}

	public String getLastName() {
		return lastName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((firstName == null) ? 0 : firstName.hashCode());
		result = prime * result + ((lastName == null) ? 0 : lastName.hashCode());
		result = prime * result + ((surName == null) ? 0 : surName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PersonName other = (PersonName) obj;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (surName == null) {
			if (other.surName != null)
				return false;
		} else if (!surName.equals(other.surName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "PersonName [firstName=" + firstName + ", lastName=" + lastName + ", surName=" + surName + "]";
	}
}
